package com.inspur.cloud.dao.dataspace;

import com.inspur.cloud.entity.dataspace.KafkaResourceEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface KafkaResourceDao extends JpaRepository<KafkaResourceEntity, Integer>, JpaSpecificationExecutor<KafkaResourceEntity> {
    List<KafkaResourceEntity> findByParentId(Integer parentId);

    KafkaResourceEntity findFirstByTopicName(String topicName);

    @Query("select h from KafkaResourceEntity h where owner=:owner AND parentId=0 ")
    KafkaResourceEntity findFirstByOwner(@Param("owner") Integer owner);
    KafkaResourceEntity findKafkaResourceEntityById(Integer id);
}
